package com.niren.relay.netty;

import java.util.Date;

import com.niren.relay.common.dt.DateTime;
import io.netty.channel.ChannelHandlerContext;

public class ClientState {
	String mac = "";
	/**
	 * 连接的上下文
	 * */
	ChannelHandlerContext ctx;
	/***
	 * 最后在线时间
	 * */
	Date lastOnlineTime;
	/**
	 * 通讯状态
	 * */
	int commStatus;
	
	/**
	 * 设备ID，也是设备在系统中的唯一标志 
	 * */
	String deviceId = "";

	public String getMac() {
		return mac;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public ChannelHandlerContext getCtx() {
	    return ctx;
	}

	public void setCtx(ChannelHandlerContext ctx) {
	    this.ctx = ctx;
	}

	public Date getLastOnlineTime() {
	    return lastOnlineTime;
	}

	public void setLastOnlineTime(Date lastOnlineTime) {
	    this.lastOnlineTime = lastOnlineTime;
	}

	public  int getTimeoutInterval(){
	    return DateTime.calcTimeMsecInterval(this.lastOnlineTime,new Date());
	}

	public int getCommStatus() {
	    return commStatus;
	}

	public void setCommStatus(int commStatus) {
	    this.commStatus = commStatus;
	}

	public int getClientTimeMsecValue(){
	    return 5000;//单秒毫秒
	}

	public void closeClient(){
	    this.ctx.close();
	}
	
	public String getDeviceId() {return this.deviceId;}
	
	public void setDeviceId(String deviceId) {this.deviceId = deviceId;}
}
